package GUI;

import java.util.Date;
import java.util.GregorianCalendar;

public class DatestringtoDate {
	static public Date getDate(String date, String time) throws Exception {
		String[] dates = date.split(".");
		if(dates.length != 3)
			throw new Exception("Wrong Dateformat! Should be DD.MM.YYYY");
		String[] times = date.split(":");
		if(times.length!=2)
			throw new Exception("Wrong Timeformat! Should be hh:mm");
		int day = Integer.parseInt(dates[0]);
		int month = Integer.parseInt(dates[1]);
		int year = Integer.parseInt(dates[2]);
		int hour = Integer.parseInt(times[0]);
		int minute = Integer.parseInt(times[1]);
		
		GregorianCalendar dateObj = new GregorianCalendar(year,month,day, hour, minute);
		
		return dateObj.getTime();
	}
}
